/*
*	This file contains all calender-related functions
*/

// populate the 'day' control when user select a month
function populate_days()
{
	var monthControl =  document.getElementById("monthReportForm");
	var yearControl = document.getElementById("yearReportForm");
	var startDayControl = document.getElementById("startDayReportForm");
	var endDayControl = document.getElementById("endDayReportForm");
	var number_of_days = daysInMonth(yearControl.options[yearControl.selectedIndex].value,monthControl.options[monthControl.selectedIndex].value);
	
	for(i=0;i<31;i++){
		startDayControl.options[i]=null;
		endDayControl.options[i]=null;
	}
	for (var i=0; i < number_of_days ; i++){
		var x= String(i+1);
		startDayControl.options[i] = new Option(x);
		endDayControl.options[i] = new Option(x);
	}
}

function daysInMonth(iYear, iMonth)
{
    return 32 - new Date(iYear, iMonth, 32).getDate();
}
